﻿@model Himall.Web.Areas.Admin.Models.Market.BonusModel
<script src="~/Scripts/jquery.himallUpload.js"></script>
<link rel="stylesheet" type="text/css" href="~/Content/bootstrap-datetimepicker.min.css">
<script type="text/javascript" src="~/Scripts/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" src="~/Scripts/bootstrap-datetimepicker.zh-CN.js"></script>
<style>
    input[type="radio"] {
        margin-top: 9px;
    }
    
    .w50 {
        width: 50px;
    }
</style>

<div class="container">
    <ul class="nav nav-tabs-custom clearfix">
        <strong>红包管理</strong>
        <li><a href="@Url.Action("Management", "Bonus", new { area = "Admin" })">管理</a></li>
        <li class="active"><a>编辑</a></li>
        <li><a href="@Url.Action("Config", "Bonus", new { area = "Admin" })">配置</a></li>
    </ul>


    @using( Html.BeginForm( "EditData" , "Bonus" , new
    {
        Area = "Admin"
    } , FormMethod.Post , new
    {
        id = "BonusForm" ,
        @class = "form-horizontal"
    } ) )
    {

        @Html.HiddenFor( p => p.Id );
        <div class="form-group">
            <label for="" class="col-sm-2 control-label">红包类型：</label>
            <div class="col-sm-3">
                @Html.RadioButtonFor( p => p.Type , ( int )Himall.Model.BonusInfo.BonusType.Activity , new
           {
               @name = "Type" ,
               @id = "rdi1" ,
           } )
                <label for="rdi1">活动红包</label>
                @Html.RadioButtonFor( p => p.Type , ( int )Himall.Model.BonusInfo.BonusType.Attention , new
           {
               @name = "Type" ,
               @id = "rdi2"
           } )
                <label for="rdi2">关注红包</label>
            </div>
            <div class="col-sm-7">
                <p class="help-default">会员第一次关注将获得红包，同一时间端内关注送红包活动只能添加一个，请确保红包金额充足</p>
            </div>
        </div>

        <div class="form-group">
            <label for="" class="col-sm-2 control-label">红包样式：</label>
            <div class="col-sm-3">
                @Html.RadioButtonFor( p => p.Style , ( int )Himall.Model.BonusInfo.BonusStyle.TempletOne , new
           {
               @name = "Style" ,
               @id = "rdi3" ,
           } )
                <label for="rdi3">源生风格</label>
                @*@Html.RadioButtonFor( p => p.Style , ( int )Himall.Model.BonusInfo.BonusStyle.TempletTwo , new
           {
               @name = "Style" ,
               @id = "rdi4"
           } )
                <label for="rdi4">模板二</label>*@
            </div>
        </div>

        <div class="form-group">
            <label for="" class="col-sm-2 control-label">商户名称：</label>
            <div class="col-sm-3">
                @Html.TextBoxFor( p => p.MerchantsName , new
           {
               @class = "form-control input-sm",
               @maxlength = "10"
           } )
            </div>
    </div>

        <div class="form-group">
            <label for="" class="col-sm-2 control-label">分享标题：</label>
            <div class="col-sm-3">
                @Html.TextBoxFor( p => p.Name , new
           {
               @class = "form-control input-sm" ,
               @maxlength = "30"
           } )
            </div>
            <div class="col-sm-7">
                <p class="help-default">活动被分享出去的链接名称，如：清凉一夏，百万现金疯狂抢</p>
            </div>
    </div>
        
        <div class="form-group">
            <label for="" class="col-sm-2 control-label">分享详情：</label>
            <div class="col-sm-3">
                @Html.TextAreaFor( p => p.Description , new
           {
               @class = "form-control input-sm"
           } )
            </div>
            <div class="col-sm-6">
                <p class="help-default">红包被分享出去后的链接详情</p>
            </div>
    </div>
        
        <div class="form-group">
            <label for="" class="col-sm-2 control-label">分享图标：</label>
            <div class="col-sm-3">
                <div id="upload-img" class="form-group upload-img"></div>
            </div>
            <div class="col-sm-6">
                <p class="help-default">活动被分享出去的链接图标</p>
            </div>
        </div>

        

        

        <div class="form-group">
            <label for="" class="col-sm-2 control-label">祝福语：</label>
            <div class="col-sm-3">
                @Html.TextBoxFor( p => p.Blessing , new
           {
               @class = "form-control input-sm",
               @maxlength = "20"
           } )
            </div>
    </div>

        <div class="form-group">
            <label for="" class="col-sm-2 control-label">备注：</label>
            <div class="col-sm-3">
                @Html.TextAreaFor( p => p.Remark , new
           {
               @class = "form-control input-sm"
           } )
            </div>
    </div>


        <div class="form-group">
            <label for="" class="col-sm-2 control-label">单个面额：</label>
            <div class="col-sm-3">

                @Html.RadioButtonFor( p => p.PriceType , ( int )Himall.Model.BonusInfo.BonusPriceType.Fixed , new
           {
               @name = "PriceType" ,
               @id = "rdi5" ,
           } )
                <label for="rdi3">固定金额</label>&nbsp;&nbsp;
                @Html.TextBoxFor( p => p.FixedAmount , new
           {
               @class = "w50"
           } ) 元 <br />

                @Html.RadioButtonFor( p => p.PriceType , (int)Himall.Model.BonusInfo.BonusPriceType.Random , new
           {
               @name = "PriceType" ,
               @id = "rdi6"
           } )
                <label for="rdi4">随机金额</label>&nbsp;&nbsp;
                @Html.TextBoxFor( p => p.RandomAmountStart , new
           {
               @class = "w50" ,
               @disabled = "true"
           } ) 至
                @Html.TextBoxFor( p => p.RandomAmountEnd , new
           {
               @class = "w50" ,
               @disabled = "true"
           } ) 元
            </div>
            <div class="col-sm-6">
                <p class="help-default">单个红包的面额。最低0.01，最高200</p>
            </div>
        </div>

        <div class="form-group">
            <label for="" class="col-sm-2 control-label">红包总面额：</label>
            <div class="col-sm-3">
                @Html.TextBoxFor( p => p.TotalPrice , new
           {
               @class = "form-control input-sm"
           } )
            </div>
    </div>

        <div class="form-group">
            <label for="" class="col-sm-2 control-label">活动开始时间：</label>
            <div class="col-sm-3">
                <input type="text" class="form-control input-sm start_datetime" name="StartTime" id="StartTime" value="@Model.StartTime.ToString( "yyyy-MM-dd" )" />
            </div>
    </div>

        <div class="form-group">
            <label for="" class="col-sm-2 control-label">活动截止时间：</label>
            <div class="col-sm-3">
                <input type="text" class="form-control input-sm end_datetime" name="EndTime" id="EndTime" value="@Model.EndTime.ToString( "yyyy-MM-dd" )" />
            </div>
            <div class="col-sm-6">
                <p class="help-default">截止日期，为领取完的红包也无法再领取</p>
            </div>
    </div>

        <div class="form-group">
            <label for="" class="col-sm-2 control-label"></label>
            <div class="col-sm-3">
                <label>关注公众号后可领取</label>
            </div>
        </div>
        
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-6">
                <label>分享后可再次领取（单个用户最多领取两次活动红包）</label>
            </div>
        </div>
        
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" id="subCate" class="btn btn-primary">保 存</button>
            </div>
        </div>
    }
</div>

<script type="text/javascript">
    $( function ()
    {
        var priceType = @((int)Model.PriceType);
        var type = @((int)Model.Type);
        var style = @((int)Model.Style);

        $( "input[name=FixedAmount]" ).attr( 'disabled', "true" );
        $( "input[name=RandomAmountEnd]" ).attr( 'disabled', "true" );
        $( "input[name=RandomAmountStart]" ).attr( 'disabled', "true" );
        $( "input[name=PriceType]" ).attr( 'disabled', "true" );
        $( "input[name=Type]" ).attr( 'disabled', "true" );
        $("#TotalPrice").attr( 'disabled', "true" );
        if ( priceType == 1 )
        {
            $( "input[name=PriceType]:eq(0)" ).attr("checked",'checked');
        }
        else if(priceType == 2)
        {
            $( "input[name=PriceType]:eq(1)" ).attr("checked",'checked');
        }
        if(type == 1)
        {
            $( "input[name=Type]:eq(0)" ).attr("checked",'checked');
            $( "#typemsg" ).addClass( "hide" );
            $( "#Name" ).parents( ".form-group" ).removeClass( "hide" );
            $( "#MerchantsName" ).parents( ".form-group" ).removeClass( "hide" );
            $( "#Remark" ).parents( ".form-group" ).removeClass( "hide" );
            $( "#Blessing" ).parents( ".form-group" ).removeClass( "hide" );
            $( "#Description" ).parents( ".form-group" ).removeClass( "hide" );
            $( "#upload-img" ).parents( ".form-group" ).removeClass( "hide" );

        }
        else if( type == 2)
        {
            $( "input[name=Type]:eq(1)" ).attr("checked",'checked');
            $( "#typemsg" ).removeClass( "hide" );
            $( "#Name" ).parents( ".form-group" ).addClass( "hide" );
            $( "#MerchantsName" ).parents( ".form-group" ).addClass( "hide" );
            $( "#Remark" ).parents( ".form-group" ).addClass( "hide" );
            $( "#Blessing" ).parents( ".form-group" ).addClass( "hide" );
            $( "#Description" ).parents( ".form-group" ).addClass( "hide" );
            $( "#upload-img" ).parents( ".form-group" ).addClass( "hide" );
        }

        if(style == 1)
        {
            $( "input[name=Style]:eq(0)" ).attr("checked",'checked');
            
        }
        else if( style == 2)
        {
            $( "input[name=Style]:eq(1)" ).attr("checked",'checked');
            
        }

        

        $( "#upload-img" ).himallUpload( {
            title: '',
            imageDescript: '',
            imgFieldName: "ImagePath",
            displayImgSrc : "@Model.ImagePath",
            dataWidth: 10
        } );

        $( ".start_datetime" ).datetimepicker( {
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            autoclose: true,
            weekStart: 1,
            beforeShow:"2012-2-2",
            minView: 2
        } );
        $( ".end_datetime" ).datetimepicker( {
            language: 'zh-CN',
            format: 'yyyy-mm-dd',
            autoclose: true,
            weekStart: 1,
            minView: 2
        } );

        $( '.start_datetime' ).on( 'changeDate', function ()
        {
            if ( $( ".end_datetime" ).val() )
            {
                if ( $( ".start_datetime" ).val() > $( ".end_datetime" ).val() )
                {
                    $( '.end_datetime' ).val( $( ".start_datetime" ).val() );
                }
            }

            $( '.end_datetime' ).datetimepicker( 'setStartDate', $( ".start_datetime" ).val() );
        } );
    } )

    function check()
    {

    }
</script>